package com.apes.scm.masterdata.product.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 * 功能：商品组
 *
 * @author HuJianlin
 * @create 2018-03-04 16:00
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = "mas_product_group")
public class ProductGroup extends Model {

    @Id
    @Column(name = "id", length = 16)
    private String id;  //商品组编码

    @Column(name = "NAME", nullable = false, length = 120)
    private String name; //商品组名称

    @Column(name = "COST_METHOD", length = 30)
    private String costMethod; //成本方法

    @Column(name = "qty_mgmt", nullable = false, columnDefinition = "number(1,0) default 1")
    private boolean qtyMgmt; //数量管理标记

    @Column(name = "aut", nullable = false, columnDefinition = "number(1,0) default 0")
    private boolean service; //服务商品标记

    @Column(name = "assets", nullable = false, columnDefinition = "number(1,0) default 0")
    private boolean assets; //材料物资标记

    @Column(name = "vip_balance", nullable = false, columnDefinition = "number(1,0) default 0")
    private boolean vipBalance;  //会员余额标记

    @Column(name = "coupons", nullable = false, columnDefinition = "number(1,0) default 0")
    private boolean coupons;  //优惠劵标记

    @Column(name = "used", nullable = false, columnDefinition = "number(1,0) default 0")
    private boolean used;  // 旧件标记

    @Column(name = "gift", nullable = false, columnDefinition = "number(1,0) default 0")
    private boolean gift;  // 赠品标记

    @Column(name = "valid", nullable = false, columnDefinition = "number(1,0) default 1")
    private boolean valid = true; //有效

    public boolean checkPartProduct(){
        if("10".equals(this.id)) return true;
        return false;
    }

    public boolean checkWorkProduct(){
        if("20".equals(this.id)) return true;
        return false;
    }

}
